package com.gxar.quick.ar.server.base.common.enums;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author linsy
 * @version 1.0
 * @created 2023/11/9 17:32
 */
public enum ComboBillMethodEnum {
    MONTH(0, "month", "包年包月"),
    AMOUNT(1, "amount", "按量");

    private final Integer code;
    private final String name;
    private final String desc;

    /**
     * 根据code查询
     *
     * @param code code
     * @return 枚举
     */
    public static ComboBillMethodEnum getByCode(Integer code) {
        ComboBillMethodEnum comboBillMethodEnum = Arrays.stream(ComboBillMethodEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        if (Objects.nonNull(comboBillMethodEnum)) {
            return comboBillMethodEnum;
        }
        return null;
    }

    ComboBillMethodEnum(Integer code, String name, String desc) {
        this.code = code;
        this.name = name;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }
}
